package Dao;

import java.util.List;

import org.apache.commons.dbutils.handlers.BeanListHandler;

import Bean.Users_Bean;
import DB.DB_DriverFactory;

public class LoginDao {
    /**
     * 用户登录验证
     * @param usersB 用户信息的实体对象
     * @return  登录的验证结果
     */
	public boolean isLogined(Users_Bean usersB){
		boolean isL=false;
		// 登录验证SQL语句
		String strSQL = "select * from EDU_USERS where USER_NAME=? and USER_PSW=?";
		List<Users_Bean> lstUsers = DB_DriverFactory.getDB_DriverInstance().query01(strSQL,
				new BeanListHandler<Users_Bean>(Users_Bean.class), new Object[] {usersB.getUser_name(),usersB.getUser_psw()});
		
		//根据查询结果判定用户是否登录成功
		if(lstUsers!=null&&lstUsers.size()>0){
			isL=true;
		}
		return isL;
	}
	
	 /**
     * 用户登录验证
     * @param usersB 用户信息的实体对象
     * @return  登录的验证结果
     */
	public List<Users_Bean> isLogined2(Users_Bean usersB){
		// 登录验证SQL语句
		String strSQL = "select * from EDU_USERS where USER_NAME=? and USER_PSW=?";
		List<Users_Bean> lstUsers = DB_DriverFactory.getDB_DriverInstance().query01(strSQL,
				new BeanListHandler<Users_Bean>(Users_Bean.class), new Object[] {usersB.getUser_name(),usersB.getUser_psw()});
		return lstUsers;
	}
}
